package com.hd.assistant.web.common.util;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;

import com.alibaba.citrus.service.pipeline.PipelineContext;
import com.alibaba.citrus.service.pipeline.support.AbstractValve;
import com.alibaba.citrus.turbine.TurbineRunDataInternal;
import com.alibaba.citrus.turbine.util.TurbineUtil;

public class DomianValve extends AbstractValve{
	 @Autowired
	 private HttpServletRequest request;
	
	public void invoke(PipelineContext pipelineContext) throws Exception {
		String reuqestUrl = request.getRequestURL().toString();
		if(reuqestUrl.contains("dacrm.com")){
			 TurbineRunDataInternal rundata = (TurbineRunDataInternal) TurbineUtil.getTurbineRunData(request);
			 rundata.setTarget("domain/dacrm");
		       
		}
		if(reuqestUrl.contains("haojiyou.cn")){
			 TurbineRunDataInternal rundata = (TurbineRunDataInternal) TurbineUtil.getTurbineRunData(request);
			 rundata.setTarget("domain/haojiyou");
		       
		}
		 pipelineContext.invokeNext();
	}

}
